Completed
Pull Request — master (#32)
by Jean
55s
created

error.test.js ➔ describe   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 29
rs 8.8571

1 Function

Rating   Name   Duplication   Size   Complexity  
A error.test.js ➔ ... ➔ describe 0 17 1
1
import chai from 'chai';
2
3
import CodingameError from '../../src/codingame/error.js';
4
5
let expect = chai.expect;
6
7
describe(`[module] codingame/error`, function() {
8
	describe(`[method] constructor`, function() {
9
		it(`should create a default CodingameError with empty message`, function() {
10
			let error = new CodingameError();
11
			expect(error).to.be.an.instanceof(CodingameError).and.has.a.property(`message`).empty;
0 ignored issues
show
introduced by
The result of the property access to expect(error).to.be.an.i...operty(`message`).empty is not used.
Loading history...
12
		});
13
		it(`should create a CodingameError with the specified message`, function() {
14
			let message = `Specified message`;
15
			let error = new CodingameError(message);
16
			expect(error).to.be.an.instanceof(CodingameError).and.has.a.property(`message`, message);
17
		});
18
		it(`should create a CodingameError from an Error`, function() {
19
			let message = `Some error`;
20
			let error = new Error(message);
21
			let cgerror = new CodingameError(error);
22
			expect(cgerror).to.be.an.instanceof(CodingameError).and.has.a.property(`message`, message);
23
		});
24
	});
25
	describe(`[method] metadata`, function() {
26
		it(`should attach metadatas to the CodingameError`, function() {
27
			let value = `42`;
28
			let meta = { "property": value };
29
			let error = new CodingameError();
30
			error.attach(meta);
31
			expect(error).to.have.a.property(`metadata`)
32
				.with.a.property(`property`, value);
33
		});
34
	});
35
});
36